package main

import (
	"gamers/Initial"
	"gamers/api"
	"github.com/fvbock/endless"
	"net/http"
)

func main() {
	// 初始化所有的中间件信息
	Initial.InitializeAll()
	// 初始化路由信息
	r := api.InitRouter()
	// 启动服务
	srv := &http.Server{
		Addr:    ":9001",
		Handler: r,
	}
	err := endless.ListenAndServe(srv.Addr, srv.Handler)
	if err != nil {
		return
	}
	// 开启一个goroutine来监听程序
	go func() {
		if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
		}
	}()
}
